package com.zhiyou100.pra;

/**
 * 学生类：
 * 为了提高程序（属性）的安全性，属性要求私有化private
 * 一旦私有化，只能自己访问，外界不能访问
 */
public class Student {

    private String name;
    private String num;
    private double score;

    //对私有属性  定义一组公开(public)的方法(set/get)，让外界访问
    public void setName(String name){
        this.name = name;
    }
    public String getName(){
        return name;
    }
    public void setNum(String num){
        this.num = num;
    }
    public String getNum(){
        return num;
    }
    //对成绩的保存或修改
    public void setScore(double score){
        if (score < 0){
            return;  //结束
        }else {
            this.score = score;
        }
    }
    //获取数据
    public double getScore(){
        return score;
    }

    public Student(String name, String num, double score) {
        this.name = name;
        this.num = num;
        this.score = score;
    }

    public Student() {
    }


}
